home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / dxtw107.zip / DXT_ME.CMD < prev    next >
OS/2 REXX Batch file  |  1995-07-20  |  9KB  |  251 lines

  1. ;*****************************************************************************
  2. ;
  3. ;   DXT_ME.CMD - MicroEMACS MACRO FUNCTIONS FOR
  4. ;
  5. ;       DFTN (TM) DBASE FUNCTION TREE NAVIGATOR
  6. ;
  7. ;   Copyright (C) Juergen Mueller (J.M.) 1992-1995
  8. ;   All rights reserved.
  9. ;
  10. ;   You are expressly prohibited from selling this software in any form,
  11. ;   distributing it with another product, or removing this notice.
  12. ;
  13. ;   Limited permission is given to registered DXT users to modify this
  14. ;   file for their own personal use only. This file may not be used for any
  15. ;   purpose other than in conjunction with the DXT software package.
  16. ;
  17. ;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  18. ;   EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE
  19. ;   IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR
  20. ;   PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  21. ;   PROGRAM AND DOCUMENTATION IS WITH YOU.
  22. ;
  23. ;   written by: Juergen Mueller, Aldingerstrasse 22, D-70806 Kornwestheim,
  24. ;               GERMANY
  25. ;
  26. ;   FILE       : DXT_ME.CMD
  27. ;   REVISION   : 26-Mar-1995
  28. ;                12:43:59
  29. ;
  30. ;*****************************************************************************
  31.  
  32. ; NOTE: for OS/2 you should exchange "dftn" with "dftn4os2"
  33. ; NOTE: for NT you should exchange "dftn" with "dftn4nt"
  34.  
  35. ;*****************************************************************************
  36. ;**** write initial message ****
  37. ;*****************************************************************************
  38. write-message "Loading DXT macro package"
  39.  
  40. ;*****************************************************************************
  41. ;**** macro package initialization section ****
  42. ;*****************************************************************************
  43. set %dxt_item ""                ; set internal variables
  44. set %dxt_file ""
  45. set %dxt_line ""
  46. set %dxtn_cmd ""
  47. set %char_set "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  48.  
  49. set %dft_base &env "DFTNBASE"   ; get environment variables, if set
  50.  
  51. ;*****************************************************************************
  52. ;**** definition of user macros ****
  53. ;*****************************************************************************
  54.  
  55. ;**** find function ****
  56. store-procedure dft
  57.         execute-procedure _extract_item         ; get tagged item
  58.         execute-procedure _dxt_dft
  59. !endm
  60.  
  61. ;**** find function ****
  62. store-procedure dftmark
  63.         execute-procedure _extract_marked_item  ; get marked item
  64.         execute-procedure _dxt_dft
  65. !endm
  66.  
  67. ;**** find function ****
  68. store-procedure dftfind
  69.         set %dxt_item "DFT function name: "
  70.         set %dxt_item @%dxt_item                ; get user input
  71.         execute-procedure _dxt_dft
  72. !endm
  73.  
  74. ;**** set DFT database name ****
  75. store-procedure dftbase
  76.         set %dft_base "DFT database name: "
  77.         set %dft_base @%dft_base                ; get user input
  78. !endm
  79.  
  80. ;**** DFT file list
  81. store-procedure dftfile
  82.         write-message "Extracting DFT filelist"
  83.  
  84.         !if ¬ &seq &len %dft_base 0
  85.           set %tmp &cat &cat "-f" %dft_base " "         ; database access path
  86.         !else
  87.           set %tmp ""
  88.         !endif
  89.  
  90.         set %dxtn_cmd &cat "dftn -F " %tmp
  91.         pipe-command %dxtn_cmd          ; perform database access, shell command
  92. !endm
  93.  
  94. ;*****************************************************************************
  95. ;**** internal macro execution functions ****
  96. ;*****************************************************************************
  97.  
  98. ;*****************************************************************************
  99. ;* DFT front-end *
  100. ;*****************************************************************************
  101. store-procedure _dxt_dft
  102.         !if &seq &len %dxt_item 0
  103.           write-message "No function selected"
  104.           !return
  105.         !endif
  106.  
  107.         write-message &cat &cat "Searching for function: '" %dxt_item "'"
  108.  
  109.         !if ¬ &seq &len %dft_base 0
  110.           set %tmp &cat &cat "-f" %dft_base " "         ; database access path
  111.         !else
  112.           set %tmp ""
  113.         !endif
  114.  
  115.         set %dxtn_cmd &cat &cat "dftn -b " %tmp %dxt_item
  116.         execute-procedure _dxt_search                   ; start search
  117. !endm
  118.  
  119. ;*****************************************************************************
  120. ;* the database retrieval function *
  121. ;*****************************************************************************
  122. store-procedure _dxt_search
  123.         set %dxt_file ""                ; clear variables
  124.         set %dxt_line ""
  125.  
  126. !force  pipe-command %dxtn_cmd          ; perform database access, shell command
  127.         !if &seq $status FALSE
  128.           !return
  129.         !endif
  130.  
  131. !force  select-buffer command           ; get result buffer from pipe-command
  132.         !if &seq $status FALSE
  133.           !return
  134.         !endif
  135.  
  136. !force  beginning-of-file               ; go to file begin
  137.         !if &seq $status FALSE
  138.           !return
  139.         !endif
  140.  
  141.         set-mark                        ; extract target file name
  142.  
  143. !force  search-forward " "              ; search for first blank after file name
  144.         !if &seq $status FALSE
  145.           !return
  146.         !endif
  147.  
  148.         backward-character
  149.         copy-region
  150.         set %dxt_file $kill             ; store target file name
  151.         forward-character
  152.         set-mark                        ; extract target file line
  153.         end-of-line
  154.         copy-region
  155.         set %dxt_line $kill             ; store target file line
  156.  
  157. !force  delete-window                   ; delete command window
  158. !force  delete-buffer command           ; delete command buffer
  159. !force  next-buffer                     ; switch to next buffer just to hide command buf
  160.  
  161.         !if ¬ &exist %dxt_file       ; test if file exists
  162.           write-message &cat &cat "Target file ~"" %dxt_file "~" not found"
  163.           !return
  164.         !endif
  165.  
  166. !force  find-file %dxt_file             ; open target file
  167.  
  168.         !if &seq $status TRUE
  169. !force    goto-line %dxt_line           ; jump to target line
  170.  
  171.           !if &seq $status FALSE
  172.             clear-message-line
  173.             !return
  174.           !endif
  175.  
  176.           delete-other-windows          ; just for safety
  177.           redraw-display                ; center target line
  178.           clear-message-line
  179.         !endif
  180. !endm
  181.  
  182. ;*****************************************************************************
  183. ;* read search item from current buffer *
  184. ;*****************************************************************************
  185. store-procedure _extract_item
  186.         set %dxt_item ""                ; clear variable
  187.  
  188.         !if &seq &sindex %char_set &chr $curchar 0
  189.           !return                       ; not on a valid character
  190.         !endif
  191.  
  192. !force  end-of-word
  193.  
  194.         !while TRUE
  195. !force  previous-word
  196. !force  backward-character
  197.         !if &seq &sindex %char_set &chr $curchar 0
  198. !force    forward-character
  199.           !break
  200.         !endif
  201.         !endwhile
  202.  
  203.         set-mark                        ; mark first item character
  204.  
  205.         !while TRUE
  206. !force  end-of-word                     ; goto end of item
  207.         !if &seq &sindex %char_set &chr $curchar 0
  208.           !break
  209.         !endif
  210.         !endwhile
  211.  
  212.         copy-region
  213.         set %dxt_item $kill             ; store item name
  214. !endm
  215.  
  216. ;*****************************************************************************
  217. ;* read marked search item *
  218. ;*****************************************************************************
  219. store-procedure _extract_marked_item
  220.         set %dxt_item ""                                ; clear variable
  221. !force  copy-region
  222.         set %dxt_item $kill                             ; store item name
  223.  
  224.         !if ¬ &seq &len %dxt_item 0
  225.           set %dxt_item &cat &cat "~"" %dxt_item "~""   ; quote
  226.         !endif
  227. !endm
  228.  
  229. ;*****************************************************************************
  230. ;* bind macros to WINDOWS menu, only if MicroEMACS for WINDOWS is present *
  231. ;*****************************************************************************
  232. !if &seq $sres "MSWIN"          ; test, if this is running under MS Windows
  233.   ; insert separator
  234.   bind-to-menu  nop     ">&Miscellaneous>-@5"
  235.  
  236.   ; create a new underlying pop-up menu for the DFT macros
  237.   macro-to-menu dft     ">&Miscellaneous>L&FT macros@6>DFT &function search@0"
  238.   macro-to-menu dftmark "DFT function search &mark"
  239.   macro-to-menu dftfind "DFT function search &prompt"
  240.   macro-to-menu dftfile "DFT file&list"
  241.   macro-to-menu dftbase "DFT data&base name"
  242. !endif
  243.  
  244. ;*****************************************************************************
  245. ;**** write final message ****
  246. ;*****************************************************************************
  247. write-message "DXT macro package loaded"
  248.  
  249. ;**** THIS IS THE END THIS IS THE END THIS IS THE END THIS IS THE END ****
  250.  
  251.